import java.util.ArrayList;
import java.util.List;

class Aggregate {

    List<Object> items = new ArrayList<Object>();

    public Iterator getIterator() {
        return new Iterator(this);
    }

    public void add(int index, Object item) {
        items.add(index, item);
    }

    public Object get(int index) {

        return items.get(index);
    }

}

class Iterator {

    public static void main(String[] args) {
        Aggregate aga = new Aggregate();
	
        aga.add(0, "A");
        aga.add(1, "B");
        aga.add(2, "C");
        
        Iterator ita = aga.getIterator();
        
        while (!ita.isDone())
        {
            System.out.println(ita.current());
            ita.next();
        }
    }

    public Aggregate Aggregate;
    int index = 0;

    public Iterator(Aggregate aggregate) {
        this.Aggregate = aggregate;
    }

    public Object first() {
        return Aggregate.get(0);
    }

    public Object next() {
        index++;
        if (index < Aggregate.items.size()) {
            return Aggregate.get(index);
        }
        return null;
    }

    public Object current() {
        return Aggregate.get(index);
    }

    public boolean isDone() {
        return index >= Aggregate.items.size();
    }
}